#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
start = time.clock()

from math import *


k = 2
result = 0

while ( k < 999999 ):
  nums = [ int(pow(int(c), 5)) for c in str(k)]
  S = sum( nums )
  if ( k == S ):
    result += k
    print k
  k += 1

print result


print "problem solved in ", (time.clock() - start), "s"
